<?php echo $this->element('menu');?>
<div class="codexecs view">
<h2><?php  __('Director Search');?></h2>
<?php if(isset($results)){
     foreach($results as $codexecs){
    ?>	
	<div style="float:left;width:200px">
	<b style="text-transform:capitalize"><?php echo $codexecs['Director']['name'];?></b><br>
	    <?php 
		$imgname=str_replace(array("-"," "),"_",strtolower($codexecs['Director']['name']));
		if(file_exists("/var/www/vhosts/investogain.com.au/httpdocs/images/Directors/".$imgname.".jpg"))
		echo '<img src="//www.investogain.com.au/images/Directors/'.$imgname.".jpg".'" alt="'.$codexecs['Director']['name'].'" width="180" />';
		elseif(file_exists("/var/www/vhosts/investogain.com.au/httpdocs/images/Directors/".$imgname.".gif"))
		echo '<img src="//www.investogain.com.au/images/Directors/'.$imgname.".gif".'" alt="'.$codexecs['Director']['name'].'" width="180" />';
		elseif(file_exists("/var/www/vhosts/investogain.com.au/httpdocs/images/Directors/".$imgname.".png"))
		echo '<img src="//www.investogain.com.au/images/Directors/'.$imgname.".png".'" alt="'.$codexecs['Director']['name'].'" width="180" />';
		else
		echo $this->Html->image('no-image.jpg', array('alt' => 'no-image','width' => '180'));?>	
	</div>	
	<div style="float:right;width:1000px">
	<b>Directorships</b><br>
	<table border="1" cellspacing="0" width="100%">
		<tr>
			<th align="left" width="300">Company</th><th align="center">Exch</th><th align="center">Status</th><th align="center">Legal Status</th><th align="center">Title</th><th align="center">Appt'd</th><th align="center">Resig'd</th><th align="center">Further Details</th>
		</tr>
	<?php foreach($codexecs['Codexec'] as $codexec){		
		$style1="color:#339966";
		$style2="color:#FF0000";
		$style3="color:#FF00FF";
		switch($codexec['Codetail']['Cat']){
			case 'l':$asx="<span style='".$style1."'>Listed</span>";break;
			case 's':$asx="<span style='".$style2."'>Suspended</span>";break;
			case 'd':$asx="<span style='".$style3."'>Delisted</span>";break;
			default :$asx="&nbsp;";break;
		}
		switch($codexec['Codetail']['Type']){
			case 'a':$legal="In administration";break;
			case 'l':$legal="In liquidation";break;
			case 'd':$legal="Deregistered";break;
			default :$legal="Registered";break;
		}
		
	?>	
		<tr>
			<td align="left"><?php echo $this->Html->link($codexec['Codetail']['ComName'], array('controller' => 'codetails', 'action' => 'view', $codexec['Codetail']['ComID']), array('target'=>'_blank')); ?>
			 (<?php echo $codexec['Codetail']['Code'];?>)</td>
			 <td align="center"><?php echo $codexec['Codetail']['Exch'];?></td>
			 <td align="center"><?php echo $asx;?></td>
			 <td align="center"><?php echo $legal;?></td>
			 <td align="center"><?php echo $codexec['DirTitle']['title'];?></td><td align="center"><?php if($codexec['App']!="0000-00-00")echo date("d/m/Y",strtotime($codexec['App']));else echo"&nbsp;";?></td><td align="center"><?php if($codexec['Resig']!="0000-00-00")echo date("d/m/Y",strtotime($codexec['Resig']));else echo"&nbsp;";?></td>
			 <td align="center"><?php if($codexec['Codetail']['director_url']!="")echo"<a href='". $codexec['Codetail']['director_url']."'>".$codexec['Codetail']['Code']." Directors</a>"; else echo $codexec['Codetail']['Code']." Directors";?></td>
		</tr>
	<?php  }?>	
	</table>	
	</div>
        
	<p style="clear:both">&nbsp;</p>
	<p style="font-weight:700;"><span style="text-transform:capitalize"><?php echo $codexecs['Director']['name'];?></span> - Change in company share price while a director</p>
	<table border="1" cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<th valign="top" align="left" width="400">Company</th>
			<th valign="top" align="center">Exch</th>
			<th valign="top" align="center" colspan="2">
				<table border="0" cellspacing="0" cellpadding="0" width="100%">
					<tr><td align="center" valign="top" colspan="2"><b>Appointment</b></td></tr>
					<tr><td align="center" width="100">Appt'd</td><td align="center">Share Pr.</td></tr>
				</table>				
			</th>
			<th valign="top" align="center" colspan="2">
				<table border="0" cellspacing="0" cellpadding="0" width="100%">
					<tr><td align="center" valign="top" colspan="2"><b>Resignation</b></td></tr>
					<tr><td align="center" width="100">Resigned</td><td align="center">Share Pr.</td></tr>
				</table>				
			</th>
			<th valign="top" align="center">
				<table border="0" cellspacing="0" cellpadding="0" width="100%">
					<tr><td align="center" valign="top"><b>Current</b></td></tr>
					<tr><td align="center">Share Pr.</td></tr>
				</table>				
			</th>
			<th valign="top" align="center" colspan="2">
				<table border="0" cellspacing="0" cellpadding="0" width="100%">
					<tr><td align="center" valign="top" colspan="2"><b>Changes %</b></td></tr>
					<tr><td align="center">Share Pr.</td><td align="center">All Ords</td></tr>
				</table>				
			</th>
		</tr>
		<?php foreach($codexecs['Codexec'] as $codexec){?>
		<tr>
			<td align="left"><?php echo $this->Html->link($codexec['Codetail']['ComName'], array('controller' => 'codetails', 'action' => 'view', $codexec['Codetail']['ComID']), array('target'=>'_blank')); ?>
			 (<?php echo $codexec['Codetail']['Code'];?>)</td>
			<td align="center"><?php echo $codexec['Codetail']['Exch'];?></td>
			<td align="center" width="100"><?php if($codexec['App']!="0000-00-00")echo date("d/m/Y",strtotime($codexec['App']));else echo"&nbsp;";?></td>	 
			<td align="center"><?php echo $codexec['AppShare'];?></td>	 
			<td align="center" width="100"><?php if($codexec['Resig']!="0000-00-00")echo date("d/m/Y",strtotime($codexec['Resig']));else echo"&nbsp;";?></td>	 
			<td align="center"><?php echo $codexec['ResigShare'];?></td>
			<td align="center"><?php echo $codexec['current_price'];?></td>
			<td align="center"><?php echo $codexec['AllShareChange'];?></td>
			<td align="center"><?php echo $codexec['AllShare'];?></td>			
		</tr>
		<?php }?>
	</table>
       
	<p style="clear:both;">&nbsp;</p>
	<p style="font-weight:700;"><span style="text-transform:capitalize"><?php echo $codexecs['Director']['name'];?></span> - On-market share transactions, most recent <span style="color:#00FF00;">purchase</span> <span style="color:red;">sales</span> first.</p>
	<?php if(isset($codexecs['Codtran']) && count($codexecs['Codtran'])>0){?>
	<table  border="1" cellspacing="0" style="width:980px">
		<tr>
			<th align="left" width="500">Company</th><th align="center">Exch</th><th align="center">Date</th><th align="center">Number</th><th align="center">Price</th><th align="center">Amount</th>
		</tr>
		<?php foreach($codtrans as $codtran){?>
		<tr>
			<td align="left"><?php echo $this->Html->link($codtran['Codtran']['Company'],array('controller' => 'codetails', 'action' => 'view', $codtran['Codtran']['ComID']), array('target'=>'_blank')); ?>
			 (<?php echo $codtran['Codtran']['Code'];?>)</td>
			<td align="center"><?php echo $codtran['Codetail']['Exch'];?></td> 
			<td align="center"><?php if($codtran['Codtran']['Date']!="0000-00-00")echo date("d M y",strtotime($codtran['Codtran']['Date']));else echo"&nbsp;";?></td>	 
			<td align="center"><?php echo $codtran['Codtran']['Number'];?></td>
			<td align="center"><?php if($codtran['Codtran']['Price']<0)echo "<span style='color:red;'>-$".$codtran['Codtran']['Price']."</span>";
			echo "<span style='color:green;'>$".$codtran['Codtran']['Price']."</span>";
			?></td>
			<td align="center"><?php echo "$".$codtran['Codtran']['Value'];?></td>
		</tr>
		<?php }?>
	</table>	
	<?php }else{?>
	<p style="clear:both">&nbsp;</p>
	<p style="font-weight:700;color:red;">No share transactions found with director <?php echo $keyword;?></p>
	<?php }?>	
<?php }}else{?>	
	<p style="clear:both">&nbsp;</p>
	<p style="font-weight:700;color:red;">No results found with director <?php echo $keyword;?></p>
<?php }?>	
</div>